package terra.ui.component;

import org.newdawn.slick.Font;
import org.newdawn.slick.Input;
import org.newdawn.slick.gui.ComponentListener;
import org.newdawn.slick.gui.GUIContext;

import terra.ui.wnd.AbstractWindow;

public class TextField extends org.newdawn.slick.gui.TextField
{
	public AbstractWindow parent;
	
	public TextField(GUIContext container, Font font, int x, int y, int width,
			int height) {
		super(container, font, x, y, width, height);
	}

	public TextField(GUIContext container, Font font, int x, int y, int width,
			int height,ComponentListener listener) {
		super(container, font, x, y, width, height,listener);
	}
	
	public void keyPressed(int key, char c) {
		if (!parent.isVisible())
			return;
		
		if (Character.isDigit(c) || (key == Input.KEY_DELETE || key == Input.KEY_BACK|| key == Input.KEY_RETURN))
			super.keyPressed(key, c);
	}
}
